package com.zs.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/fr")
public class ForwardAndRedirectController {
    /*
    * 1 方法也不能使用@ReqyestBody
    * 2 方法返回值类型String
    * 3 return "forward | redirect : path"  path地址一样 都是项目下地址！ 不要写项目根路径  /
    * */

    @GetMapping("/zhuanfa")
    public String zhuanfa(){
        System.out.println("zhuanfa");
        return "forward:/fr/target";
    }
    @GetMapping("/chongdingxiang")
    public String chongdingxiang(){
        System.out.println("chongdingxiang");
        return "redirect:/fr/target";
    }
    @GetMapping("/baidu")
    public String baidu(){
        System.out.println("chongdingxiang");
        return "redirect:http://www.baidu.com";
    }
    @ResponseBody
    @GetMapping("/target")
    public String target(){
        System.out.println("target");
        return "target";
    }


}
